<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="dashboard/header :: header"></head>
<body>
	<div layout:fragment="content">
		<div class="container-fluid content-main">
			<div class="animated fadeIn">
				<div class="row">
					<!-- /.col-->
					<div class="col-sm-12">
						<div class="card">
							<div class="card-body">

								<form class="form-horizontal" id="addForm">

									<input type="hidden" name="formToken" th:value="${session.formToken}" />
								
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label" for="text-input">所属应用</label>
										<div class="col-md-9">
											<input class="form-control" id="text-input" type="text" onclick="showApplication()" 
												   name="applicationIdLabel" readonly="readonly" style="cursor: pointer" placeholder="所属应用">
											<input type="hidden" name="applicationId"  />
										</div>
									</div>
										
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label" for="text-input">标题</label>
										<div class="col-md-9">
											<input class="form-control" id="text-input" type="text" name="postTitle" placeholder="标题">
										</div>
									</div>
									
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label" for="email-input">文章类型</label>
										<div class="col-md-9">
											<select class="form-control" id="postMimeType" name="postMimeType">
												<option th:each="item:${codeTypes}" th:value="${item.id}" th:text="${item.typeName}" selected></option>
											</select>
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label" for="email-input">内容</label>
										<div class="col-md-9">
											<textarea class="form-control" id="postContent" name="postContent" rows="8" placeholder="内容"></textarea>
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label" for="email-input">是否发布</label>
										<div class="col-md-9">
											<page:dict type="common_status" name="hasStatus" />	
										</div>
									</div>
								</form>

							</div>

						</div>
					</div>
				</div>
			</div>
		</div>

	</div>

	<footer th:replace="dashboard/footer :: footer"></footer>
	<script type="text/javascript" th:src="@{/resources/js/project.js}"></script>
	
	<!-- kindeditor_start -->
	<link rel="stylesheet" th:href="@{/asserts/ajax/libs/kindeditor/themes/default/default.css}" />
	<script charset="utf-8" th:src="@{/asserts/ajax/libs/kindeditor/kindeditor-all-min.js}"></script>
	<script charset="utf-8" th:src="@{/asserts/ajax/libs/kindeditor/lang/zh-CN.js}"></script>
	<!-- kindeditor_end -->
	
	<script type="text/javascript">
		
		KindEditor.ready(function(K) {
			var editor = K.create('textarea[name="postContent"]', {
				uploadJson : '../jsp/upload_json.jsp',
				fileManagerJson : '../jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() { this.sync(); }, //关键是这两个
				afterBlur: function(){this.sync();} //关键是这两个
			});
			editor.edit.setHeight('300px');
		});
		
		$(function(){
			$("#addForm").validate({
				ignore: [],  
				rules: {
					applicationId: "required",
					postTitle: "required",
					postMimeType: "required",
					postContent: "required",
					password: "required"
				}
			});
		}) ;
		
		function submitHandler() {
			var result = $.validate.form("addForm");
			if(result){
				$.operate.save(ctx+"portal/ucenter/content/save" , $('#addForm').serialize());
			}
		}
		
	</script>

</body>
</html>
